import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 故障类型信息 */
export interface FaultClassification {
  id: number // id
  name?: string // 故障类型
  status: number // 状态
  description: string // 描述
}

// 故障类型 API
export const FaultClassificationApi = {
  // 查询故障类型分页
  getFaultClassificationPage: async (params: any) => {
    return await request.get({ url: `/business/fault-classification/page`, params })
  },

  // 查询故障类型详情
  getFaultClassification: async (id: number) => {
    return await request.get({ url: `/business/fault-classification/get?id=` + id })
  },

  // 新增故障类型
  createFaultClassification: async (data: FaultClassification) => {
    return await request.post({ url: `/business/fault-classification/create`, data })
  },

  // 修改故障类型
  updateFaultClassification: async (data: FaultClassification) => {
    return await request.put({ url: `/business/fault-classification/update`, data })
  },

  // 删除故障类型
  deleteFaultClassification: async (id: number) => {
    return await request.delete({ url: `/business/fault-classification/delete?id=` + id })
  },

  /** 批量删除故障类型 */
  deleteFaultClassificationList: async (ids: number[]) => {
    return await request.delete({
      url: `/business/fault-classification/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出故障类型 Excel
  exportFaultClassification: async (params) => {
    return await request.download({ url: `/business/fault-classification/export-excel`, params })
  },

  // 下载导入模板
  importEqupmentTemplate: async () => {
    return request.download({ url: '/business/fault-classification/get-import-template' })
  },

  // 查询所有列表
  getFaultClassificationList: async () => {
    return await request.get({ url: `/business/fault-classification/list` })
  },

  //==易损品模块====================================
  // 查询故障类型分页
  getFaultClassificationPageDamage: async (params: any) => {
    return await request.get({ url: `/Damage/fault-classification/page`, params })
  },

  // 查询故障类型详情
  getFaultClassificationDamage: async (id: number) => {
    return await request.get({ url: `/Damage/fault-classification/get?id=` + id })
  },

  // 新增故障类型
  createFaultClassificationDamage: async (data: FaultClassification) => {
    return await request.post({ url: `/Damage/fault-classification/create`, data })
  },

  // 修改故障类型
  updateFaultClassificationDamage: async (data: FaultClassification) => {
    return await request.put({ url: `/Damage/fault-classification/update`, data })
  },

  // 删除故障类型
  deleteFaultClassificationDamage: async (id: number) => {
    return await request.delete({ url: `/Damage/fault-classification/delete?id=` + id })
  },

  /** 批量删除故障类型 */
  deleteFaultClassificationListDamage: async (ids: number[]) => {
    return await request.delete({
      url: `/Damage/fault-classification/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出故障类型 Excel
  exportFaultClassificationDamage: async (params) => {
    return await request.download({ url: `/Damage/fault-classification/export-excel`, params })
  },

  // 下载导入模板
  importEqupmentTemplateDamage: async () => {
    return request.download({ url: '/Damage/fault-classification/get-import-template' })
  },

  // 查询所有列表
  getFaultClassificationListDamage: async () => {
    return await request.get({ url: `/Damage/fault-classification/list` })
  }
}
